package com.qk.management.controller;

import com.qk.common.Result;
import com.qk.common.api.SmsApi;
import com.qk.common.util.SmsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author:gzc
 * @Date: 2025/10/09 18:43
 * @Description:
 */
@RestController
public class SmsController {

    @Autowired
    private SmsApi smsApi;
    @GetMapping("/sms")
    public Result sendSms(@RequestParam String phone) throws Exception {
        Map<String, String> querys = new HashMap<>();
        querys.put("mobile", phone);
        querys.put("templateId", "JM1000372");
        String randomCode = SmsUtils.getRandomCode(6);
        querys.put("value", randomCode);
        smsApi.sendSms(querys);
        return Result.success();
    }
}
